home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
prodpack.zip
/
DB4PPSRC.EXE
/
_CATCURR.PRG
< prev
next >
Wrap
Text File
|
1993-05-04
|
4KB
|
124 lines
PROCEDURE _CatCurr
PARAMETER pc_result
*--------------------------------------------------------------------
* NAME
* _CatCurr - Get the current catalog
*
* DESCRIPTION
* The _CatCurr procedure will return the current catalog name
* regardless of the state of the catalog. CatCurr
* will use the CATALOG() function first. If that does not work,
* it will try to open the first CATALOG.CAT in the PATH and use
* it. _CatCurr() will then use the ALIAS value for
* the last record in CATALOG.CAT as the return value.
*
* If _CatCurr cannot find a CATALOG.CAT file,
* it will return a blank value. The return value will have
* no PATH prefix.
*
* _CatCurr() overcomes the oversight of the
* CATALOG() function returning a value only if a CATALOG
* is active.
*
* SYNOPSYS
* DO _CatCurr WITH <pc_result>
*
* PARAMETERS
* pc_result = Name if the catalog file. Blank if a catalog is
* not located. It is forced to blank at the start.
*
* EXAMPLE
* SET CATALOG TO samples
* ? CATALOG() && Built in returns "SAMPLES.CAT"
* lc_catname = ""
* DO _CatCurr WITH lc_catname && lc_catname equals "SAMPLES.CAT"
*
* SET CATALOG TO && Shut down the catalog
* ? CATALOG() && Built in returns ""
* DO _CatCurr WITH lc_catname && lc_catname equals "SAMPLES.CAT"
*
* LIMITATIONS
* Fields must be off, Talk must be off
*
* DEPENDENCIES
* Called by: _CatOpen - Open the current catalog file
*
* VARIABLES
* ll_fpath = State of FULLPATH, .T. if on, .F. if off
* ll_delete = State of DELETE, .T. if on, .F. if off
* ll_catalog = State of CATALOG, .T. if on, .F. if off
* lc_alias = Current WA alias in use
* lc_hcat = Full path name of CATALOG.CAT in the dBASE HOME() dir
*
*--------------------------------------------------------------------
PRIVATE ll_fpath, ll_delete, lc_alias, lc_hcat
pc_result = "" && Catalog name to return
ll_fpath = SET("FULLPATH") = "ON" && Save the fullpath state
SET FULLPATH ON && Force fullpath on
pc_result = CATALOG() && Try the catalog() first
*-- If no catalog, look for the catalog using the dBASE search method
IF ISBLANK( pc_result )
lc_alias = ALIAS() && Save the current alias
SELECT SELECT() && Get a new work area
ll_catalog = SET( "CATALOG" ) = "ON"
SET CATALOG OFF
ON ERROR DO _F_Error
*-- Check for CATALOG.CAT in PATH
IF FILE( "catalog.cat" )
USE catalog.cat ALIAS FXCatCat AGAIN NOUPDATE NOLOG
ELSE
lc_hcat = HOME() + "CATALOG.CAT" && Form the home directory cat name
IF FILE( lc_hcat ) && If the home catalog.cat exists
USE ( lc_hcat ) ALIAS FXCatCat AGAIN NOUPDATE NOLOG
ENDIF
ENDIF
*-- Check for open CATALOG.CAT with DBF()
IF .NOT. ISBLANK( DBF() )
ll_delete = SET( "DELETE" ) = "ON" && Save the delete state
SET DELETE ON && Do not show deleted records
GO BOTTOM && Move to the current cat record
pc_result = UPPER( TRIM( path ) ) && Store file name to the result
USE && Close Catalog.cat
IF .NOT. ll_delete && If delete was off before
SET DELETE OFF && Set delete off
ENDIF
ELSE
RELEASE FXL_Error
ENDIF
IF .NOT. ISBLANK( lc_alias ) && If a file was open before
SELECT ( lc_alias ) && Reset the work area back
ENDIF
IF ll_catalog
SET CATALOG ON
ENDIF
ENDIF
IF .NOT. ll_fpath && If fullpath was off before
SET FULLPATH OFF && Set fullpath back off
ENDIF
RETURN
*-- EOP: _CatCurr WITH pc_result